<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- qopenglversionfunctions.cpp -->
  <title>QAbstractOpenGLFunctions Class | Qt GUI 5.14.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QAbstractOpenGLFunctions</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.14.2 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#protected-functions">Protected Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QAbstractOpenGLFunctions Class</h1>
<!-- $$$QAbstractOpenGLFunctions-brief -->
<p>The QAbstractOpenGLFunctions class is the base class of a family of classes that expose all functions for each OpenGL version and profile. <a href="#details">More...</a></p>
<!-- @@@QAbstractOpenGLFunctions -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QAbstractOpenGLFunctions&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 5.1</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherited By:</td><td class="memItemRight bottomAlign"> <p><a href="qopenglfunctions-1-0.html">QOpenGLFunctions_1_0</a>, <a href="qopenglfunctions-1-1.html">QOpenGLFunctions_1_1</a>, <a href="qopenglfunctions-1-2.html">QOpenGLFunctions_1_2</a>, <a href="qopenglfunctions-1-3.html">QOpenGLFunctions_1_3</a>, <a href="qopenglfunctions-1-4.html">QOpenGLFunctions_1_4</a>, <a href="qopenglfunctions-1-5.html">QOpenGLFunctions_1_5</a>, <a href="qopenglfunctions-2-0.html">QOpenGLFunctions_2_0</a>, <a href="qopenglfunctions-2-1.html">QOpenGLFunctions_2_1</a>, <a href="qopenglfunctions-3-0.html">QOpenGLFunctions_3_0</a>, <a href="qopenglfunctions-3-1.html">QOpenGLFunctions_3_1</a>, <a href="qopenglfunctions-3-2-compatibility.html">QOpenGLFunctions_3_2_Compatibility</a>, <a href="qopenglfunctions-3-2-core.html">QOpenGLFunctions_3_2_Core</a>, <a href="qopenglfunctions-3-3-compatibility.html">QOpenGLFunctions_3_3_Compatibility</a>, <a href="qopenglfunctions-3-3-core.html">QOpenGLFunctions_3_3_Core</a>, <a href="qopenglfunctions-4-0-compatibility.html">QOpenGLFunctions_4_0_Compatibility</a>, <a href="qopenglfunctions-4-0-core.html">QOpenGLFunctions_4_0_Core</a>, <a href="qopenglfunctions-4-1-compatibility.html">QOpenGLFunctions_4_1_Compatibility</a>, <a href="qopenglfunctions-4-1-core.html">QOpenGLFunctions_4_1_Core</a>, <a href="qopenglfunctions-4-2-compatibility.html">QOpenGLFunctions_4_2_Compatibility</a>, <a href="qopenglfunctions-4-2-core.html">QOpenGLFunctions_4_2_Core</a>, <a href="qopenglfunctions-4-3-compatibility.html">QOpenGLFunctions_4_3_Compatibility</a>, <a href="qopenglfunctions-4-3-core.html">QOpenGLFunctions_4_3_Core</a>, <a href="qopenglfunctions-4-4-compatibility.html">QOpenGLFunctions_4_4_Compatibility</a>, <a href="qopenglfunctions-4-4-core.html">QOpenGLFunctions_4_4_Core</a>, <a href="qopenglfunctions-4-5-compatibility.html">QOpenGLFunctions_4_5_Compatibility</a>, <a href="qopenglfunctions-4-5-core.html">QOpenGLFunctions_4_5_Core</a>, and <a href="qopenglfunctions-es2.html">QOpenGLFunctions_ES2</a></p>
</td></tr></table></div><p>This class was introduced in Qt 5.1.</p>
<ul>
<li><a href="qabstractopenglfunctions-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qabstractopenglfunctions.html#dtor.QAbstractOpenGLFunctions">~QAbstractOpenGLFunctions</a></b>()</td></tr>
</table></div>
<a name="protected-functions"></a>
<h2 id="protected-functions">Protected Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qabstractopenglfunctions.html#QAbstractOpenGLFunctions-1">QAbstractOpenGLFunctions</a></b>()</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QAbstractOpenGLFunctions-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>OpenGL implementations on different platforms are able to link to a variable number of OpenGL functions depending upon the OpenGL ABI on that platform. For example, on Microsoft Windows only functions up to those in OpenGL 1.1 can be linked to at build time. All other functions must be resolved at runtime. The traditional solution to this has been to use either <a href="qopenglcontext.html#getProcAddress">QOpenGLContext::getProcAddress</a>() or <a href="qopenglfunctions.html">QOpenGLFunctions</a>. The former is tedious and error prone and means dealing directly with function pointers. The latter only exposes those functions common to OpenGL ES 2 and desktop OpenGL. There is however much new OpenGL functionality that is useful when writing real world OpenGL applications.</p>
<p>Qt now provides a family of classes which all inherit from QAbstractOpenGLFunctions which expose every core OpenGL function by way of a corresponding member function. There is a class for every valid combination of OpenGL version and profile. Each class follows the naming convention:</p>
<pre class="cpp plain">

  QOpenGLFunctions_&lt;MAJOR VERSION&gt;_&lt;MINOR VERSION&gt;[_PROFILE]

</pre>
<p>For OpenGL versions 1.0 through to 3.0 there are no profiles, leading to the classes:</p>
<ul>
<li><a href="qopenglfunctions-1-0.html">QOpenGLFunctions_1_0</a></li>
<li><a href="qopenglfunctions-1-1.html">QOpenGLFunctions_1_1</a></li>
<li><a href="qopenglfunctions-1-2.html">QOpenGLFunctions_1_2</a></li>
<li><a href="qopenglfunctions-1-3.html">QOpenGLFunctions_1_3</a></li>
<li><a href="qopenglfunctions-1-4.html">QOpenGLFunctions_1_4</a></li>
<li><a href="qopenglfunctions-1-5.html">QOpenGLFunctions_1_5</a></li>
<li><a href="qopenglfunctions-2-0.html">QOpenGLFunctions_2_0</a></li>
<li><a href="qopenglfunctions-2-1.html">QOpenGLFunctions_2_1</a></li>
<li><a href="qopenglfunctions-3-0.html">QOpenGLFunctions_3_0</a></li>
</ul>
<p>where each class inherits from QAbstractOpenGLFunctions.</p>
<p>OpenGL version 3.1 removed many deprecated functions leading to a much simpler and generic API.</p>
<p>With OpenGL 3.2 the concept of profiles was introduced. Two profiles are currently defined for OpenGL: Core and Compatibility.</p>
<p>The Core profile does not include any of the functions that were removed in OpenGL 3.1&#x2e; The Compatibility profile contains all functions in the Core profile of the same version plus all of the functions that were removed in OpenGL 3.1&#x2e; In this way the Compatibility profile classes allow use of newer OpenGL functionality but also allows you to keep using your legacy OpenGL code. For new OpenGL code the Core profile should be preferred.</p>
<p>Please note that some vendors, notably Apple, do not implement the Compatibility profile. Therefore if you wish to target new OpenGL features on macOS then you should ensure that you request a Core profile context via <a href="qsurfaceformat.html#setProfile">QSurfaceFormat::setProfile</a>().</p>
<p>Qt provides classes for all version and Core and Compatibility profile combinations. The classes for OpenGL versions 3.1 through to 4.3 are:</p>
<ul>
<li><a href="qopenglfunctions-3-1.html">QOpenGLFunctions_3_1</a></li>
<li><a href="qopenglfunctions-3-2-core.html">QOpenGLFunctions_3_2_Core</a></li>
<li><a href="qopenglfunctions-3-2-compatibility.html">QOpenGLFunctions_3_2_Compatibility</a></li>
<li><a href="qopenglfunctions-3-3-core.html">QOpenGLFunctions_3_3_Core</a></li>
<li><a href="qopenglfunctions-3-3-compatibility.html">QOpenGLFunctions_3_3_Compatibility</a></li>
<li><a href="qopenglfunctions-4-0-core.html">QOpenGLFunctions_4_0_Core</a></li>
<li><a href="qopenglfunctions-4-0-compatibility.html">QOpenGLFunctions_4_0_Compatibility</a></li>
<li><a href="qopenglfunctions-4-1-core.html">QOpenGLFunctions_4_1_Core</a></li>
<li><a href="qopenglfunctions-4-1-compatibility.html">QOpenGLFunctions_4_1_Compatibility</a></li>
<li><a href="qopenglfunctions-4-2-core.html">QOpenGLFunctions_4_2_Core</a></li>
<li><a href="qopenglfunctions-4-2-compatibility.html">QOpenGLFunctions_4_2_Compatibility</a></li>
<li><a href="qopenglfunctions-4-3-core.html">QOpenGLFunctions_4_3_Core</a></li>
<li><a href="qopenglfunctions-4-3-compatibility.html">QOpenGLFunctions_4_3_Compatibility</a></li>
</ul>
<p>where each class inherits from QAbstractOpenGLFunctions.</p>
<p>A pointer to an object of the class corresponding to the version and profile of OpenGL in use can be obtained from <a href="qopenglcontext.html#versionFunctions-1">QOpenGLContext::versionFunctions</a>(). If obtained in this way, note that the <a href="qopenglcontext.html">QOpenGLContext</a> retains ownership of the object. This is so that only one instance need be created.</p>
<p>Before calling any of the exposed OpenGL functions you must ensure that the object has resolved the function pointers to the OpenGL functions. This only needs to be done once per instance with initializeOpenGLFunctions(). Once initialized, the object can be used to call any OpenGL function for the corresponding version and profile. Note that initializeOpenGLFunctions() can fail in some circumstances so check the return value. Situations in which initialization can fail are if you have a functions object for a version or profile that contains functions that are not part of the context being used to resolve the function pointers.</p>
<p>If you exclusively use function objects then you will get compile time errors if you attempt to use a function not included in that version and profile. This is obviously a lot easier to debug than undefined behavior at run time.</p>
</div>
<p><b>See also </b><a href="qopenglcontext.html#versionFunctions-1">QOpenGLContext::versionFunctions</a>().</p>
<!-- @@@QAbstractOpenGLFunctions -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QAbstractOpenGLFunctions$$$QAbstractOpenGLFunctions -->
<h3 class="fn" id="QAbstractOpenGLFunctions-1"><a name="QAbstractOpenGLFunctions-1"></a><code>[protected] </code>QAbstractOpenGLFunctions::<span class="name">QAbstractOpenGLFunctions</span>()</h3>
<p>Constructs a QAbstractOpenGLFunctions object.</p>
<!-- @@@QAbstractOpenGLFunctions -->
<!-- $$$~QAbstractOpenGLFunctions[overload1]$$$~QAbstractOpenGLFunctions -->
<h3 class="fn" id="dtor.QAbstractOpenGLFunctions"><a name="dtor.QAbstractOpenGLFunctions"></a><code>[virtual] </code>QAbstractOpenGLFunctions::<span class="name">~QAbstractOpenGLFunctions</span>()</h3>
<p>Destroys a <a href="qabstractopenglfunctions.html">QAbstractOpenGLFunctions</a> object.</p>
<!-- @@@~QAbstractOpenGLFunctions -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
